class PermissoesController {
    
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete:'POST', save:'POST', update:'POST']

    def list = {
        if(!params.max) params.max = 10
        [ permissoesInstanceList: Permissoes.list( params ) ]
    }

    def show = {
        def permissoesInstance = Permissoes.get( params.id )

        if(!permissoesInstance) {
            flash.message = "Permissoes not found with id ${params.id}"
            redirect(action:list)
        }
        else { return [ permissoesInstance : permissoesInstance ] }
    }

    def delete = {
        def permissoesInstance = Permissoes.get( params.id )
        if(permissoesInstance) {
            permissoesInstance.delete()
            flash.message = "Permissoes ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "Permissoes not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def permissoesInstance = Permissoes.get( params.id )

        if(!permissoesInstance) {
            flash.message = "Permissoes not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ permissoesInstance : permissoesInstance ]
        }
    }

    def update = {
        def permissoesInstance = Permissoes.get( params.id )
        if(permissoesInstance) {
            permissoesInstance.properties = params
            if(!permissoesInstance.hasErrors() && permissoesInstance.save()) {
                flash.message = "Permissoes ${params.id} updated"
                redirect(action:show,id:permissoesInstance.id)
            }
            else {
                render(view:'edit',model:[permissoesInstance:permissoesInstance])
            }
        }
        else {
            flash.message = "Permissoes not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def permissoesInstance = new Permissoes()
        permissoesInstance.properties = params
        return ['permissoesInstance':permissoesInstance]
    }

    def save = {
        def permissoesInstance = new Permissoes(params)
        if(!permissoesInstance.hasErrors() && permissoesInstance.save()) {
            flash.message = "Permissoes ${permissoesInstance.id} created"
            redirect(action:show,id:permissoesInstance.id)
        }
        else {
            render(view:'create',model:[permissoesInstance:permissoesInstance])
        }
    }
}
